package com.shanghaiyimu.yimiyangche.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.adapter.QuanBuDingdanAdapter;
import com.shanghaiyimu.yimiyangche.bean.DingDanNum;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class QuanBuDingdanFragment extends Fragment {


    public QuanBuDingdanFragment() {
        // Required empty public constructor
    }

    private ListView listView;
    private QuanBuDingdanAdapter adapter;
    private List<DingDanNum> datas = new ArrayList<>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_quan_bu_dingdan, container, false);
        initView(view);
        iniData();
        return view;
    }

    private void iniData() {
        for (int i = 0; i < 10; i++) {
            DingDanNum danNum = new DingDanNum();
            danNum.setName("SUV/MPV 标准洗车"+i);
            danNum.setContent(i);
            danNum.setPrice(15+i);
            datas.add(danNum);
        }
        adapter.notifyDataSetChanged();
    }

    void initView(View view){
        listView = (ListView) view.findViewById(R.id.quanbudingdan_listview);
        adapter = new QuanBuDingdanAdapter(getContext(),datas);
        listView.setAdapter(adapter);
    }

}
